<!--
 * @author: sanbao
 * @Date: 2022-09-05 14:56:57
-->
<style lang='scss' scoped>
#echarts1 {
  width: 100%;
  height: 100%;
}
</style>
<template>
  <div id="echarts1"></div>
</template>

<script>
import { ref, reactive, toRefs, computed, onMounted } from "vue";
import { a } from "../api/index";
export default {
  components: {},
  setup() {
    onMounted(() => {
      getdocument();
    });
    const getdocument = async () => {
      let myChart = echarts.init(document.getElementById("echarts1"));
      let xAxislist = [];
      let yAxislist = [];
      const response = await a;
      response.countryAddConfirmRankList.forEach((v) => {
        xAxislist.push(v.nation);
        yAxislist.push(v.addConfirm);
      });

      myChart.setOption({
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "shadow",
          },
        },
        grid: {
          right: "3%",
          left: "10%",
          bottom: "12%",
          top: "5%",
        },
        xAxis: [
          {
            type: "category",
            data: xAxislist,
            axisLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.12)",
              },
            },
            axisLabel: {
              margin: 10,
              color: "#e2e9ff",
              textStyle: {
                fontSize: 14,
              },
            },
          },
        ],
        yAxis: [
          {
            axisLine: {
              show: false,
              lineStyle: {
                color: "rgba(255,255,255,1)",
              },
            },
            splitLine: {
              lineStyle: {
                color: "rgba(255,255,255,0.12)",
              },
            },
          },
        ],
        series: [
          {
            type: "bar",
            data: yAxislist,
            barWidth: "20px",
            itemStyle: {
              normal: {
                color: "rgba(0,77,167,1)",
                barBorderRadius: [30, 30, 30, 30],
                shadowColor: "rgba(0,160,221,1)",
                shadowBlur: 4,
              },
            },
          },
        ],
      });
      window.onresize = function () {
        myChart.resize();
      };
    };
    return {};
  },
};
</script>
